package com.kpiJavaTraining.bogdan.module2;

import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectOutputStream;
import java.io.OutputStream;

/**
 * Class saves the TestStack in a file
 * @author Bogdan Olexandr
 *
 */
public class Saver {

	private OutputStream output;
	private ObjectOutputStream data;
		
	/**
	 * method saves the TestStack in a file
	 * @param testStack
	 * @throws IOException
	 */
	public void save(TestStack testStack) throws IOException {
		output = new FileOutputStream(testStack.getUser().toString()+".ucl");
		data = new ObjectOutputStream(output);
		data.writeObject(testStack);
		data.flush();
		data.close();
	}
}
